<?php

class MDEItineraryDraw
{

public static $instance; 

public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new MDEItineraryDraw();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	
    
    
function DrawTable($title,$table,$growtable,$campos,$idPackTour)//obligatorio ID como campo inicial
    {
        
    $qu = "SELECT   `tour_has_track`.`idTourTrack`, `tour_has_track`.`OrdTrack`, `tour_has_track`.`DateBegTrack` ,  `tour_has_track`.`DateEndTrack` ,  `tour_has_track`.`OrdTrack` ,  `track`.`OriTrack` , `track`.`IntTrack` ,  `track`.`DestTrack`  FROM tour_has_track LEFT JOIN  `viv`.`track` ON  `tour_has_track`.`TRACK_idTrack` =  `track`.`idTrack` WHERE ((TOUR_idTour =$idPackTour)AND (TOUR_idTour =$idPackTour)) order by `tour_has_track`.`OrdTrack` ASC";

    echo "<div id='content_area_user_title'>";
    echo "<h2> $title</h2>";
    echo "</div>";
    echo	"<form>";						
    echo "<form id='filter-form'>Filtrar día del itinerario: <input name='filter' id='filter' value='' maxlength='30' size='30' type='text'></form><br>";
    echo "</form>";  
    echo "<div class='usersettings_statistics'>"; 
    
    
    echo "<table class='food_planner'><thead><tr>";
    
    echo "<thead>";
    echo "<tr>";    
     foreach($campos as $id=>$valor){
  
    echo "<th>$valor</th>";
    
    }

    echo "</tr>";    
    echo "</thead>";
    
    
    echo "<tbody><tr style='display: table-row;'>";

     //echo "<table> <tbody>";



 echo "<tr class='odd'>";
  
    // $qu="select*from $table";
    $table=CModelo::getInstance()->getData($qu);
//var_dump($table);
    $cont=0;
    $ruta=CConfig::getInstance()->rutalocal."/MDItinerary";
    
    
    foreach($table as $campo => $valor)
    { 



$cont=$cont+1;
if($cont%2){




echo "<tr class='odd'>";
$i="";$cont=0;
foreach($valor as $id=>$val)
{ if($cont==0){$i=$val;}

//echo "<td>     <input type='text' name='$id' class='general-textarea' value='$val'>"."</label> </td>";
echo "<td>$val </td>";$cont=$cont+1;
}
/*---------------------------------------------------------------------------*/
// las referencias debbden de ser modificadas deacuerdo al directorio
//
/*---------------------------------------------------------------------------*/



echo "<td> <a href='$ruta/MDItineraryEdit.php?codigo=$i'> <img src='../images/edit.png' width='32' title='Editar track $i'/></a> </td>";
echo "<td><a href='/christian/modificar.php?codigo=$i'> <img src='../images/trash.png' width='32' title='Eliminar restaurante $i'/> </a> </td>";

echo "</tr>";
}
else
{

echo "<tr class='even'> ";
$i2="";$cont2=0;
foreach($valor as $id => $val)
{ if($cont2==0){$i2=$val;}
echo "<td>$val </td>";$cont2=$cont2+1;
}
echo "<td> <a href='$ruta/MDItineraryEdit.php?codigo=$i2'> <img src='../images/edit.png' width='32' title='Editar track $i2'/></a> </td>";
echo "<td><a href='/christian/modificar.php?codigo=$i2'> <img src='../images/trash.png' width='32' title='Eliminar restaurante $i2'/> </a> </td>";
echo "</tr>";
}

}
echo "</td></tr></tbody></table><br><br>";


echo "</div>";

} 



}
?>